package com.bjtang.book.dto;

import javax.validation.constraints.Email;

import org.hibernate.validator.constraints.Length;

import com.baomidou.mybatisplus.annotation.TableField;
import com.bjtang.book.entiy.SysUser;
import com.bjtang.book.util.RSA加密;

import lombok.Data;

//注册
@Data
public class LogonDto {
	// 登录验证码
	// @NonNull
	@Length(min = 4, max = 4)
	private String yzm;
	// 姓名
	@Length(min = 1, max = 50)
	private String name;
	// 邮箱
	@Email
	@Length(min = 0, max = 100)
	private String email;
	// 手机
	@Length(min = 0, max = 19)
	private String phone;
	// 地址
	@Length(min = 0, max = 500)
	private String userAddress;
	// 登陆名
	@Length(min = 4, max = 64)
	private String loginName;
	// 密码
	@Length(min = 6, max = 128)
	@TableField(select = false) // 查询结果不显示
	private String password;

	public SysUser getUser() {
		SysUser user = new SysUser();
		user.setName(this.name);
		user.setEmail(this.email);
		user.setPhone(this.phone);
		user.setUserAddress(this.userAddress);
		user.setLoginName(this.loginName);
		user.setPassword(new RSA加密().加密(this.password));
		return user;
	}

}
